package com.tadpole.music.view.activity.me.yun;

import android.content.pm.ActivityInfo;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;

import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import com.tadpole.music.R;
import com.tadpole.music.utils.NoDoubleClickListener;
import com.tadpole.music.view.activity.base.BaseActivity;


/**
 * 全屏视频播放页面
 * Created by SunYan
 * on 2020/4/17.
 */
public class FullVideoActivity extends BaseActivity {
    private StandardGSYVideoPlayer vpVideo;
    private RelativeLayout rlBack;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_full_video);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        fullScreen();

        vpVideo = findViewById(R.id.vpVideo);
        rlBack = findViewById(R.id.rlBack);

        String a = getIntent().getStringExtra("label");
        vpVideo.setUp(a,true,"");
        vpVideo.getFullscreenButton().setVisibility(View.GONE);
        vpVideo.getBackButton().setVisibility(View.GONE);
        vpVideo.getTitleTextView().setVisibility(View.GONE);
        vpVideo.startPlayLogic();
        rlBack.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                FullVideoActivity.this.finish();
            }
        });
//        vpVideo.startWindowFullscreen(this,true,true);
    }

    //全屏
    private void fullScreen() {
        if (Build.VERSION.SDK_INT >= 19) {
            View decorView = getWindow().getDecorView();
            decorView.setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        } else {
            View decorView = getWindow().getDecorView();
            int option = View.SYSTEM_UI_FLAG_FULLSCREEN;
            decorView.setSystemUiVisibility(option);
        }

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        GSYVideoManager.releaseAllVideos();
    }
}
